<?php

class Document_Factory extends Zend_Db_Table_Rowset
{
	
	static protected $_classMap = array(55 => 'Claim');
	const CLASS_NAMESPACE = 'Document';

    public function current()
    {
        $document_type = $this->_data[$this->_pointer]['type'];

        $class_name = $this->getDocumentClass($document_type);
	    spl_autoload_call($class_name);
	    $this->_rowClass = $class_name;
        
        return parent::current();
    }
    
    static public function getDocumentClass($type)
    {
    	return (array_key_exists($type,self::$_classMap)) 
    	    ? self::CLASS_NAMESPACE . '_' . self::$_classMap[$type]
    	    : self::CLASS_NAMESPACE;   
    }
}
